using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Ltf.Diffs;

namespace Ltf.MonitorLizard.Forms
{
	public partial class MergedOutputForm : Form
	{
		MergeOutputControl moControl;
		TwoWayDiffControl twdControl;
		Control previousMoHost;

		public MergedOutputForm(Ltf.Diffs.TwoWayDiffControl twowayDiff, MergeOutputControl mergeOutput)
		{
			InitializeComponent();
			twdControl = twowayDiff;
			moControl = mergeOutput;
			previousMoHost = moControl.Parent;
			moControl.Parent=this.toolStripContainer1.ContentPanel;
			moControl.Focus();
			moControl.ChangeRegionListBuilt += new EventHandler(moControl_ChangeRegionListBuilt);
		}

		void moControl_ChangeRegionListBuilt(object sender, EventArgs e)
		{
			tsslConflicts.Text = string.Format("Conflicts:{0}", moControl.DiffDocument.NumberOfConflicts);
			tsslMerges.Text = string.Format("Merges:{0}", moControl.DiffDocument.NumberOfMerges);
			tsslResolutions.Text = string.Format("Resolution:{0}", moControl.DiffDocument.NumberOfResolutions);
			tsslUndoneMerges.Text = string.Format("Undone Merges:{0}", moControl.DiffDocument.NumberOfUndoneMerges);
		}

		protected override void OnClosing(CancelEventArgs e)
		{
			moControl.ChangeRegionListBuilt -= new EventHandler(moControl_ChangeRegionListBuilt);
			moControl.Parent = previousMoHost;
			base.OnClosing(e);
		}

		private void toolStripButton4_Click(object sender, EventArgs e)
		{
			moControl.Next();
		}

		private void toolStripButton3_Click(object sender, EventArgs e)
		{
			moControl.Previous();
		}

		private void tsbFind_Click(object sender, EventArgs e)
		{
			moControl.FindNext(tsbTxtFind.Text);
		}

		private void tsbFindPrevious_Click(object sender, EventArgs e)
		{
			moControl.FindPrevious(tsbTxtFind.Text);
		}
	}
}